Skip to main content

WeChat chat history export to computer txt file tutorial

The ultimate goal of this article is to export mobile phone WeChat chat logs to your computer as txt text files and then analyse them.

There are some tools online that can also do this, but they are basically paid for. If you do it manually, you've searched a lot of blogs, but basically nothing is completely effective. I eventually found a very reliable tutorial: Portal, and this article is basically based on this one for finishing.

Considering the privacy of the group, the source data is not provided in this article.

Exporting the mobile WeChat database

The first step to take is to export the WeChat database .db file from the mobile phone to your computer.

One way to do this is to go to /data/data/com.tencent.mm/MicroMsg and find the three files underneath after rooting, but many people don't go to root, so another method is described.

apps\com.tencent.mm\r\MicroMsg\systemInfo.cfg
apps\com.tencent.mm\r\MicroMsg\CompatibleInfo.cfg
apps\com.tencent.mm\r\MicroMsg\xxxx\EnMicroMsg.db

The most important step is to back up your phone's chat history to your computer's WeChat, then restore your computer's chat history to WeChat in Android Virtualizer, which comes with WeChat and should not be difficult.

Then root the Android Virtualizer, which is also right there in the settings, and finally you can copy all three files to the computer.

Cracking the database password

Put all the above files all in one directory.

Then on the command line run the following code.

javac IMEI.java
java IMEI systemInfo.cfg CompatibleInfo.cfg

The third line of the output is the password for the database.

Exporting the chat log

Then open the sqlcipher.exe software and use it to open the EnMicroMsg.db database and enter the password you got in the previous step.

在这里插入图片描述

This will show a lot of tables, click on File-Export-Table as CSV file in the Excel menu bar, select the message table and export.

If you open this table directly in Excel, it may display garbled codes. So create a new excel table, click on Data-From-Text and import this .csv file.

In the box that pops up, select GB2312 for the first drop down box and load it, then it will not be garbled.

Then in the talker column select the chat you want to filter by, click on the content column and copy it into the message.txt text.

Finally run the following code from the command line to remove invalid messages.

python3 process_wechat.py message.txt

This produces a __message.txt, which is the finished chat log.

Generating a word cloud

This was covered in the last blog, check out.地址

最后的效果如图所示

在这里插入图片描述